index/ajax.<!DOCTYPE html>
<html lang="en">
    <head>
        {include file="public/header" /}
    </head>
    <body>

        <p><b>在输入框中输入一个姓名:</b></p>
        <form> 
            姓名: <input type="text" onkeyup="showHint(this.value)">
        </form>
        <p>返回值: <span id="txtHint"></span></p>
        
        {include file="public/footer" /}
        <script type="text/javascript">
         function showHint(str)
         {
             xmlhttp=new XMLHttpRequest();

             xmlhttp.onreadystatechange = function()
             {
                 if (xmlhttp.readyState==4 && xmlhttp.status==200)
                     
                     {
                         console.log(xmlhttp.responseText);
                         if(xmlhttp.responseText === ''){
                             
                         }
                         document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
                     }

                 if(xmlhttp.readyState == 1){
                     
                 }
             }
             xmlhttp.open("post","index/ajax?id="+str,true);
             xmlhttp.setRequestHeader("CONTENT-TYPE", "mulitpart/form-data");
             /*              xmlhttp.setRequestHeader("CONTENT-one", "application/x-www-form-urlencoded"); */

             xmlhttp.send();
         }
        </script>
    </body>
</html>
